package context;

import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;

//import javax.microedition.lcdui.Graphics;
//import myGUI.PopupText;

public final class Context
{ private static MIDlet MIDLET;
  private static Display DISPLAY;

//  public interface Constants
//  { static final boolean DEBUG=true; //false;
//    static final boolean LOG_XML=true;//false;
//    static final boolean LOG_PLAY_EVENT=true;
//  }
  
  public static boolean TRACING=false;
//  private static PopupText tracePanel=new PopupText("Trace");
//  public static void trace(String s) { tracePanel.add(s); }
//  public static void paintTracing(Graphics g,int width,int height)
//  {	if(tracePanel!=null)
//    { tracePanel.setDimension(width,height);
//      tracePanel.paint(g);
//    }
//  }
  
  public static void setMidlet(MIDlet midlet)
  { MIDLET=midlet;
    DISPLAY=Display.getDisplay(MIDLET);
  }
  
  public static MIDlet getMidlet() { return(MIDLET); }
  
  public static Display getDisplay()
  { if(DISPLAY==null) Debug.ERROR("Context.getDisplay: Context is not initiated");
	  return(DISPLAY);
  }

  public static Displayable setCurrent(Displayable displayable)
  { Displayable prev=getDisplay().getCurrent();
    getDisplay().setCurrent(displayable);
    return(prev);
  }

  
  public static void showError(String msg)  { new ErrorScreen(msg); }

  public static void exit() { MIDLET.notifyDestroyed(); }

}
